#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
	pid_t pid;
	char *arg_list[] = {"prog-name","execout","execin",NULL};
	char *env_list[] = {"USER=unknown","PATH=/tmp:/usr/bin:.",NULL};
	pid=vfork();
	if(pid==0)//child process
	{
		printf("Before Executing NewProgram by the Child..\n");
		//use any one of the exec variations to execute the program p0-which will print command-line
		//arguments and environment list -- refer p0.c
		execve("/home/nsatvik/USP/process-prgs-2012/unhuff",arg_list,env_list);
	/*	execle("/home/nsatvik/USP/process-prgs-2012/p0","p0","first-argument","second-argument",(char *)0,env_list); //(char *)0 is NULL
		execv("/home/nsatvik/USP/process-prgs-2012/p0",arg_list); 
		execl("/home/nsatvik/USP/process-prgs-2012/p0","p0","first-argument","second-argument",(char *)0);
		execvp("p0",arg_list); //this will work only if home directory is included in PATH, or copy P0 to bin
		execlp("p0","p0","first-argument","second-argument",(char *)0);

	*/	//guess! are the following lines get executed...refer Note:
		printf("Child Terminating..\n");
		exit(0);
	}
	if(waitpid(pid,NULL,0)<0){perror("waitpid");exit(1);}
	exit(0);
}

/*
NOte: No chance, because on execution of exec, old text segment is completely replaced by the new code

     -but this code execute if exec fails
*/
